package com.example.cangku.web.dao;

import com.example.cangku.web.dataobject.WangruqingCangku;
import java.util.List;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.springframework.web.bind.annotation.RequestMapping;

@Mapper
public interface WangruqingCangkuMapper {
    @Delete({
        "delete from wangruqing_cangku",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into wangruqing_cangku (id, hang, ",
        "lie, kind, time)",
        "values (#{id,jdbcType=INTEGER}, #{hang,jdbcType=INTEGER}, ",
        "#{lie,jdbcType=INTEGER}, #{kind,jdbcType=VARCHAR},now())"
    })
    int insert(WangruqingCangku record);

    @Select({
        "select",
        "id, hang, lie, kind, time",
        "from wangruqing_cangku",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="hang", property="hang", jdbcType=JdbcType.INTEGER),
        @Result(column="lie", property="lie", jdbcType=JdbcType.INTEGER),
        @Result(column="kind", property="kind", jdbcType=JdbcType.VARCHAR),
        @Result(column="time", property="time", jdbcType=JdbcType.TIMESTAMP)
    })
    WangruqingCangku selectByPrimaryKey(Integer id);

    @Select({
            "select",
            "id, hang, lie, kind, time",
            "from wangruqing_cangku",
            "where hang=#{hang,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="hang", property="hang", jdbcType=JdbcType.INTEGER),
            @Result(column="lie", property="lie", jdbcType=JdbcType.INTEGER),
            @Result(column="kind", property="kind", jdbcType=JdbcType.VARCHAR),
            @Result(column="time", property="time", jdbcType=JdbcType.TIMESTAMP)
    })
    List<WangruqingCangku> selectByHang(int hang);

    @Select({
            "select",
            "id, hang, lie, kind, time",
            "from wangruqing_cangku",
            "where hang=#{lie,jdbcType=INTEGER}"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="hang", property="hang", jdbcType=JdbcType.INTEGER),
            @Result(column="lie", property="lie", jdbcType=JdbcType.INTEGER),
            @Result(column="kind", property="kind", jdbcType=JdbcType.VARCHAR),
            @Result(column="time", property="time", jdbcType=JdbcType.TIMESTAMP)
    })
    List<WangruqingCangku> selectByLie(int lie);


    @Select({
            "select",
            "id, hang, lie, kind, time",
            "from wangruqing_cangku",
            "where kind=#{kind,jdbcType=VARCHAR}"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
            @Result(column="hang", property="hang", jdbcType=JdbcType.INTEGER),
            @Result(column="lie", property="lie", jdbcType=JdbcType.INTEGER),
            @Result(column="kind", property="kind", jdbcType=JdbcType.VARCHAR),
            @Result(column="time", property="time", jdbcType=JdbcType.TIMESTAMP)
    })
    List<WangruqingCangku> selectByKind(String kind);

    @Select({
        "select",
        "id, hang, lie, kind, time",
        "from wangruqing_cangku"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="hang", property="hang", jdbcType=JdbcType.INTEGER),
        @Result(column="lie", property="lie", jdbcType=JdbcType.INTEGER),
        @Result(column="kind", property="kind", jdbcType=JdbcType.VARCHAR),
        @Result(column="time", property="time", jdbcType=JdbcType.TIMESTAMP)
    })
    List<WangruqingCangku> selectAll();

    @Update({
        "update wangruqing_cangku",
        "set hang = #{hang,jdbcType=INTEGER},",
          "lie = #{lie,jdbcType=INTEGER},",
          "kind = #{kind,jdbcType=VARCHAR},",
          "time = now()",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(WangruqingCangku record);
}